<template>
  <div class="app-container">
    
    <div class="hello">  
        <ul>  
    <form @submit.prevent="onSubmit">  
                <input type="text" name="username" v-model="result.name">  
                 
                <input type="submit" value="提交">  
            </form>  
             </ul>  
    </div> 
  </div>
</template>

<script>
import { updateUser, getById } from '@/modules/user/model/user'
export default {
  props: ['id'],
  data() {
    return {
      result: {
        id: '',
        name: ''

      }

    }
  },
  created() {
    this.fetchData(this.id)
  },

  methods: {
    fetchData(id) {
      getById(id).then(response => {
        this.result = response.data.data.item
      })
    },
    onSubmit() {
      updateUser(this.result).then(response => {
        alert('提交成功')
      })
    }
  }
}
</script>
